package com.xianbeiying.app.ckgl.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.xianbeiying.app.ckgl.R;
import com.xianbeiying.app.ckgl.util.LogUtils;

import java.util.ArrayList;

/**
 * 选择农作物数据适配
 */
public class CpChoiceContentdapter extends  RecyclerView.Adapter<CpChoiceContentdapter.MyViewHolder>{
    private ArrayList<String> arrayList;
    public ArrayList<String> getArrayList() {
        return arrayList;
    }
    public void setArrayList(ArrayList<String> arrayList) {
        this.arrayList = arrayList;
    }
    private Context context;

    public CpChoiceContentdapter(Context context) {
        super();
        this.context = context;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        MyViewHolder holder = new MyViewHolder(LayoutInflater.from(context).inflate(R.layout.item_cp_choice, parent,
                false));
        return holder;
    }
    @Override
    public int getItemCount(){
        LogUtils.e("----", getArrayList().size()+"====");
        return getArrayList().size();
    }
    @Override
    public void onBindViewHolder(MyViewHolder holder, int position){
        LogUtils.e("----", getArrayList().get(position)+"===="+position);
          holder.tv_cp_type.setText(getArrayList().get(position));
    }

    class MyViewHolder extends RecyclerView.ViewHolder
    {
        TextView tv_cp_type;
        public MyViewHolder(View view)
        {
            super(view);
            tv_cp_type = (TextView) view.findViewById(R.id.tv_cp_type);
        }
    }
}
